package com.mrx.commons.utils.reflect;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author Mr.X
 * @since 2024-01-12 15:57
 **/
public interface InvocationHandlerHelper extends InvocationHandler {

    @Override
    default Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method.getName().equals("toString")) {
            return InvocationHandlerHelper.class + "$ENHANCED_BY_MrX";
        }
        if (method.getDeclaringClass().equals(Object.class)) {
            return method.invoke(this, args);
        }
        return invoke(method, args);
    }

    Object invoke(Method method, Object[] args) throws Throwable;

}
